// 接口请求二次封装
import request from '../utils/request';

export const fetchData = query => {
    return request({
        url: './table.json',
        method: 'get',
        params: query
    });
};
// *************************登录************************************
// 登录接口
export function loginAdmin(username, password) {
    const data = {
        username,
        password
    }
    return request({
        url: '/auth/loginAdmin',
        method: 'post',
        data
    })
}
// *************************券************************************
// 创建type接口 POST /wx/auth/createType
export function createType(name, pid,url) {
    const data = {
        name: name,
        pid: pid,
		url:url
    }
    return request({
        url: '/auth/createType',
        method: 'post',
        data
    })
}

export function createImg(url,img) {
    const data = {
        img: img,
        url:url
    }
    return request({
        url: '/auth/createImg',
        method: 'post',
        data
    })
}

//POST /wx/auth/createQuan   创建券

export function createQuan(data) {
    // console.log(data)
    return request({
        url: '/auth/createQuan',
        method: 'post',
        data
    })
}


// POST /wx/auth/queryByType   获取券类型
export function queryByType(data) {
    // console.log(data)
    return request({
        url: '/auth/queryByType',
        method: 'post',
        data
    })
}

// POST /wx/auth/queryByType   获取券类型
export function queryByImg(data) {
    // console.log(data)
    return request({
        url: '/auth/queryByImg',
        method: 'post',
        data
    })
}

//具体券列表、    /wx/quan/selectQuan	
export function selectQuan(data) {
    // console.log(data)
    return request({
        url: '/quan/selectQuan',
        method: 'post',
        data
    })
}
// 所有券
export function selectAllQuan() {
    // console.log(data)
    return request({
        url: '/quan/selectAllQuan',
        method: 'post',
    })
}

// *************************用户************************************


// POST /wx/auth/queryAllUser     搜索所有用户
export function queryAllUser(data) {
    // console.log(data)
    return request({
        url: '/auth/queryAllUser',
        method: 'post',
        data
    })
}


// POST /wx/auth/createUser            创建用户
export function createUser(data) {
    console.log(data)
    return request({
        url: '/auth/createUser',
        method: 'post',
        data
    })
}

// *************************商户************************************
// regist     创建商户
export function regist(data) {
    console.log(data)
    return request({
        url: '/usergoods/regist',
        method: 'post',
        data
    })
}

// 商户列表    http://192.168.0.112:8088//wx/usergoods/usergoodslist

export function usergoodslist() {
    // console.log(data)
    return request({
        url: '/usergoods/usergoodslist',
        method: 'get',
    })
}

//批量创建
export function createUsers(data) {
    return request({
        url: '/auth/createUsers',
        method: 'post',
		data
    })
}

// 停用启用 post   http://192.168.0.112:8088///wx/usergoods/stat
export function stat(data) {
    return request({
        url: '/usergoods/updateStat',
        method: 'post',
		data
    })
}

// 停用启用 post   http://192.168.0.112:8088///wx/usergoods/stat
export function statQuan(data) {
    return request({
        url: '/quan/updateStat',
        method: 'post',
        data
    })
}

export function deleteType(data) {
    return request({
        url: '/auth/deleteType',
        method: 'delete',
        data
    })
}

export function deleteImg(data) {
    return request({
        url: '/auth/deleteImg',
        method: 'delete',
        data
    })
}

// 删除  delete请求  http://192.168.0.112:8088///wx/usergoods/delete
export function deleteIt(data) {
    return request({
        url: '/usergoods/deleteId',
        method: 'delete',
		data
    })
}

// // 图片上传   http://192.168.0.100:8088///wx/auth/createImage
export function createImage(data) {
    return request({
        url: '/auth/createImage',
        method: 'post',
		data
    })
}
